package com.hdd.art.biz.show.controller;
import com.hdd.art.biz.show.dto.*;
import com.hdd.art.biz.show.entity.ArtShow;
import com.hdd.art.biz.show.entity.ArtShowSetup;
import com.hdd.art.biz.show.service.ArtShowService;
import com.hdd.art.biz.show.service.ArtShowSetupService;
import com.hdd.art.dto.AppResponse;
import com.hdd.art.utils.IdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;

/**
 * <p>
 * 美术馆 前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-06-27
 */
@RestController
@RequestMapping("/art-show")
@Api(value = "美术馆",tags = {"美术馆相关"})
public class ArtShowController {


    @Autowired
    private ArtShowService artShowService;
    @Autowired
    private ArtShowSetupService artShowSetupService;

    @PostMapping("/findArtById")
    @ApiOperation(value = "美术馆详情" ,notes = "")
    public AppResponse info(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        ArtShow artShow = artShowService.findArtShowById(artShowDo.getArtId());
        ArtShowVo vo = new ArtShowVo();
        BeanUtils.copyProperties(artShow,vo);
        vo.setFans(111000);
        vo.setNewFans(12);
        vo.setWorks(100);
        vo.setShare(1001);
        vo.setTrial(100);
        vo.setShows(1000);
        vo.setNewTrial(14);
        response.setItem(vo);
        return response;
    }

    @PostMapping("/updateArt")
    @ApiOperation(value = "美术馆修改" ,notes = "")
    public AppResponse update(@Valid @RequestBody ArtShowInfoDo artShowDo ){
        AppResponse response = new AppResponse();
        ArtShow artShow = new  ArtShow();
        BeanUtils.copyProperties(artShowDo,artShow);
        artShowService.updateShow(artShow);
        return response;
    }

    @PostMapping("/updateArtSynopsis")
    @ApiOperation(value = "美术馆修改-简介" ,notes = "")
    public AppResponse updateArtSynopsis(@Valid @RequestBody UpdateArtSynopsisDto artShowDo ){
        AppResponse response = new AppResponse();
        ArtShow artShow = new  ArtShow();
        BeanUtils.copyProperties(artShowDo,artShow);
        artShowService.updateShow(artShow);
        return response;
    }

    @PostMapping("/rule")
    @ApiOperation(value = "美术馆投稿规则" ,notes = "")
    public AppResponse rule(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        response.setItem(artShowSetupService.findArtShowSetup(artShowDo.getArtId()));
        return response;
    }

    @PostMapping("/agreement")
    @ApiOperation(value = "投稿协议" ,notes = "")
    public AppResponse agreement(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        response.setItem(artShowSetupService.agreement(artShowDo.getArtId()));
        return response;
    }

    @PostMapping("/updateRule")
    @ApiOperation(value = "美术馆投稿规则修改" ,notes = "")
    public AppResponse updateRule(@Valid @RequestBody ArtShowSetupDto artShowSetupDto ){
        AppResponse response = new AppResponse();
        ArtShowSetup artShowSetup = new ArtShowSetup();
        BeanUtils.copyProperties(artShowSetupDto,artShowSetup);
        artShowSetupService.update(artShowSetup);
        return response;
    }

    @PostMapping("/create")
    @ApiOperation(value = "美术馆创建" ,notes = "")
    public AppResponse create(@Valid @RequestBody ArtShowInfoDo artShowDo ){
        AppResponse response = new AppResponse();
        ArtShow artShow = new  ArtShow();
        BeanUtils.copyProperties(artShowDo,artShow);
        artShow.setArtId(IdUtils.getShartUUID());
        artShowService.addArtShow(artShow);
        response.setItem(artShow.getArtId());
        return response;
    }

    @PostMapping("/myArtRecord")
    @ApiOperation(value = "我逛过的美术馆" ,notes = "")
    public AppResponse myArtRecord(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        response.setItems(artShowService.myArtRecord(artShowDo.getUserId()));
        return response;
    }

}

